package com.njupt.simulation.service.Impl;

import com.njupt.simulation.Mapper.*;
import com.njupt.simulation.entity.GeoSatellite;
import com.njupt.simulation.entity.LeoSatellite;
import com.njupt.simulation.entity.Link;
import com.njupt.simulation.service.CalculateCarrierService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class CalculateCarrierServiceImpl implements CalculateCarrierService {

    @Autowired
    private SceneMapper sceneMapper;
    @Autowired
    private LeoSatelliteMapper leoSatelliteMapper;
    @Autowired
    private GeoSatelliteMapper geoSatelliteMapper;
    @Autowired
    private StationMapper stationMapper;
    @Autowired
    private IMTBaseMapper imtBaseMapper;
    @Autowired
    private IMTMapper imtMapper;
    @Autowired
    private MobileTerminalMapper mobileTerminalMapper;
    @Autowired
    private AdjacentBandMapper adjacentBandMapper;

    /**
     * 计算受扰链路的载波功率
     *
     * @param disturbedLink 受扰链路链表
     * @return
     */
    @Override
      public double calculatecarrier(List<Link> disturbedLink) {
//        double pt;//发射功率
//        double gt;//发射增益
//        double gr;//接收增益
//        double lf;
//        for (Link disturbedlink : disturbedLink) {
//            /*
//            计算发射功率、发射增益
//             */
//            //如果发射端是低轨卫星
//            if ("leosatellite".equals(disturbedlink.getTransType()) || "constellation".equals(disturbedlink.getTransType())) {
//                LeoSatellite leoSatellite = leoSatelliteMapper.findById(disturbedlink.getTransId());
//                //如果使用的低轨卫星的馈电链路
//                if ("feederlink".equals(disturbedlink.getLinkType())) {
//                    pt = leoSatellite.getFeederTransmitPower();
//                    if ("ITU1528".equals(leoSatellite.getAntennaConfigType())) {
//                        gt = leoSatellite.getGain();
//                    } else if ("equivalentLine".equals(leoSatellite.getAntennaConfigType())) {
//                        gt = 0;
//                    }
//                }//如果使用的是用户链路
//                else if ("userlink".equals(disturbedlink.getLinkType())) {
//                    pt = leoSatellite.getUserTransmitPower();
//                    if ("ITU1528".equals(leoSatellite.getAntennaConfigType())) {
//                        gt = leoSatellite.getGain();
//                    } else if ("equivalentLine".equals(leoSatellite.getAntennaConfigType())) {
//                        gt = 0;
//                    }
//                }
//            }
//            else if("geosatellite".equals(disturbedlink.getTransType())){
//                GeoSatellite geoSatellite = geoSatelliteMapper.findById(disturbedlink.getTransId());
//                if ("feederlink".equals(disturbedlink.getLinkType())) {
//                    pt = geoSatellite.getFeederTransmitPower();
//                    if ("ITU1528".equals(geoSatellite.getAntennaConfigType())) {
//                        gt = geoSatellite.getGain();
//                    } else if ("equivalentLine".equals(geoSatellite.getAntennaConfigType())) {
//                        gt = 0;
//                    }
//                }//如果使用的是用户链路
//                else if ("userlink".equals(disturbedlink.getLinkType())) {
//                    pt = geoSatellite.getUserTransmitPower();
//                    if ("ITU1528".equals(geoSatellite.getAntennaConfigType())) {
//                        gt = geoSatellite.getGain();
//                    } else if ("equivalentLine".equals(geoSatellite.getAntennaConfigType())) {
//                        gt = 0;
//                    }
//                }
//            }
//        }
        return 0;
    }

}